@extends('layout.main')

@section('content')
    <div class="alert alert-success" role="alert">
        下面是搜索
        <label>“ {{ $query }} ”</label>
        出现的文章，共 {{ $posts->total() }} 条
    </div>

    <div class="col-sm-8 blog-main">
        @foreach($posts as $post)
        <div class="blog-post">
            <h2 class="blog-post-title"><p onclick="location.href=this.dataset.url" data-url="/posts/{{ $post->id }}" >{{ $post->title }}</p></h2>
            <p class="blog-post-meta"> {{ $post->created_at->toFormattedDateString() }} by <a href="/user/{{ $post->user->id }}"> {{ $post->user->name }} </a></p>
            <div> {!! str_limit(strip_tags($post->content), 200, '...') !!} </div>
        </div>
        @endforeach

        {{ $posts->links() }}
    </div><!-- /.blog-main -->
@endsection